#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<vector>

using namespace std;

struct ListNode {
    int val;
    ListNode *next;
    ListNode() : val(0), next(nullptr) {}
    ListNode(int x) : val(x), next(nullptr) {}
    ListNode(int x, ListNode *next) : val(x), next(next) {}
};
 
class Solution {
public:
    ListNode* reverseBetween(ListNode* head, int left, int right) {
        if (left >= right)
        {
            return head;
        }

        vector<ListNode*> v;
        ListNode* cur = head;
        while (cur != nullptr)
        {
            v.push_back(cur);
            cur = cur->next;
        }

        reverse(v.begin() + left - 1, v.begin() + right);

        head = v[0];
        for (int i = 1; i < v.size(); i++)
        {
            v[i - 1]->next = v[i];
        }
        v[v.size() - 1]->next = nullptr;

        return head;
    }


    int lengthOfLongestSubstring(string s)
    {
        int i = 0;
        int max = 0;
        int count = 0;
        for (i = 0; i < s.size(); i++)
        {
            int a[128] = { 0 };
            a[s[i]]++;
            count = 1;
            for (int j = i + 1; j < s.size(); j++)
            {
                a[s[j]]++;
                if (a[s[j]] < 2)
                {
                    count++;
                }
                else
                {
                    if (count > max)
                    {
                        max = count;

                    }break;
                }
            }
            if (count > max)
            {
                max = count;
            }
        }


        return max;
    }
};

int main()
{
    Solution S;
    return 0;
}